package com.bpc.cs.dto;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.bpc.cs.constant.DBConstant;

/**
 * @author   phan_tp
 * @datetime Nov 30, 2012 : 2:02:55 PM
 */

@Entity
@Table (name = DBConstant.TBL_SCORING_FACTOR)
public class FactorDTO {
	@Id
	@SequenceGenerator(name = "generator_factor", sequenceName = "factor_id_seq",
			   		   catalog = "CREDIT_SCORING", schema = "SCREDIT_SCORING", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator_factor")
	@Column (name = DBConstant.COL_SF_ID, unique = true, nullable = false)
	private int factorID;

	@Column (name = DBConstant.COL_SF_NAME, unique = true, nullable = false)
	private String factorName;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "factorDTO")
	@Cascade(CascadeType.ALL)
	@Fetch(FetchMode.SELECT)
	private Set<RuleDTO> ruleDTO;

	/**
	 * Default contructor
	 */
	public FactorDTO() {}

	/**
	 * Contructor init factor name
	 * @param factorName
	 */
	public FactorDTO(String factorName) {
		this.factorName = factorName;
	}

	/**
	 * @return the factorID
	 */
	public int getFactorID() {
		return factorID;
	}

	/**
	 * @param factorID the factorID to set
	 */
	public void setFactorID(int factorID) {
		this.factorID = factorID;
	}

	/**
	 * @return the name
	 */
	public String getFactorName() {
		return factorName;
	}

	/**
	 * @param factorName the factorName to set
	 */
	public void setFactorName(String factorName) {
		this.factorName = factorName;
	}

	/**
	 * @return the ruleDTO
	 */
	public Set<RuleDTO> getRuleDTO() {
		return ruleDTO;
	}

	/**
	 * @param ruleDTO the ruleDTO to set
	 */
	public void setRuleDTO(Set<RuleDTO> ruleDTO) {
		this.ruleDTO = ruleDTO;
	}


}
